package test.fresh.things.junit;

import java.io.IOException;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class JUMule {

	private static final String DEFAULT_NAME = "MULE";
	Mule mule01 = new Mule("Micha", 3, 150);
	Mule mule02 = mule01;
	Mule mule03 = new Mule("Pena", 2, 100);
	Mule mule04 = new Mule("Pena", 2, 100);

	@Before
	public void load() {
		System.out.println("@Before load() method");
		mule01.setWeight(300);
		mule03.setName("Marko");

		System.out.println(mule01);
		System.out.println(mule02);
		System.out.println(mule03);
		System.out.println("---------------\n");
	}

	// @Test(expected=IOException.class)
	@Test
	public void testCalcCapacityCoef() {
		System.out.println("@Test testCalcCapacityCoef()");
		System.out.println(12345 + 5432l);
		// assertions

		Assert.assertEquals("Mules are nor equal.", mule01, mule02);
		// Assert.assertEquals("Mules are nor equal.", mule01, mule03);
		// Assert.fail("conscious Fail");
		Assert.assertEquals("Not Equal Weight", mule01.getWeight(), mule02
				.getWeight());
//		Assert.assertEquals("Not Equal Weight", mule01.getWeight(), mule03
//				.getWeight());
		
		Object obj=null;
//		Object obj2= new Object();
//		Assert.assertNotNull(obj);
		Assert.assertNull(obj);
//		Assert.assertNull(obj2);
		
		Assert.assertSame(mule01, mule02);
//		Assert.assertSame(mule03, mule04);
//		Assert.assertFalse(mule01==mule02);
		Assert.assertFalse(mule03==mule04);
//		Assert.assertTrue(mule03==mule04);
		
		

		try {
			mule01.calculateCapacityCoeficient(6);
		} catch (IOException ioe) {
			AssertionError ae = new AssertionError("Error");
			ae.initCause(ioe);
			throw ae;
		}

		System.out.println("---------------\n");
	}

	@After
	public void release() {
		System.out.println("@After release() method");
		mule01.setName(DEFAULT_NAME);
		System.out.println(mule01);
		System.out.println("---------------\n");
	}
}
